/*!
\copyright  Copyright (c) 2020 - 2021 Qualcomm Technologies International, Ltd.
            All Rights Reserved.
            Qualcomm Technologies International, Ltd. Confidential and Proprietary.
\version    %%version
\file       headset_leds_config_table.c
\brief      Headset led configuration table module
*/
#include "headset_leds_config_table.h"
#include "headset_led.h"
#include "headset_sm.h"

#include <domain_message.h>
#include <ui_indicator_leds.h>
#include <pairing.h>
#include <battery_region.h>
#include <charger_monitor.h>
#include <power_manager.h>
#include <telephony_messages.h>
#include <hfp_profile.h>
#include <av.h>
#include <system_state.h>
#include <media_player.h>
#include <voice_sources.h>

const ui_provider_context_consumer_indicator_table_t headset_ui_leds_context_indications_table[] =
{
    {.provider=ui_provider_app_sm,
     .context=context_app_sm_rf_dut,                    { .led.action = LED_START_PATTERN,
                                                          .led.data.pattern = app_led_rf_dut,/*0x00*/
                                                          .led.priority = LED_PRI_MEDIUM,
                                                          .led.local_only = TRUE }},
    {.provider=ui_provider_handset_pairing,
     .context=context_handset_pairing_active,           { .led.action = LED_START_PATTERN,
                                                          .led.data.pattern = app_led_pattern_pairing,/*0x01*/
                                                          .led.priority = LED_PRI_LOW,
                                                          .led.local_only = TRUE }},
    {.provider=ui_provider_telephony,
     .context=context_voice_ringing_incoming,           { .led.action = LED_START_PATTERN,
                                                          .led.data.pattern = app_led_pattern_call_incoming,/*0x02*/
                                                          .led.priority = LED_PRI_LOW,
                                                          .led.local_only = TRUE }},
    {.provider=ui_provider_telephony,
     .context=context_voice_ringing_outgoing,           { .led.action = LED_START_PATTERN,
                                                          .led.data.pattern = app_led_pattern_sco,/*0x03*/
                                                          .led.priority = LED_PRI_LOW,
                                                          .led.local_only = TRUE }},
    {.provider=ui_provider_telephony,
     .context=context_voice_in_call,                    { .led.action = LED_START_PATTERN,
                                                          .led.data.pattern = app_led_pattern_sco,/*0x04*/
                                                          .led.priority = LED_PRI_LOW,
                                                          .led.local_only = TRUE }},
    {.provider=ui_provider_telephony,
     .context=context_voice_in_call_with_incoming,      { .led.action = LED_START_PATTERN,
                                                          .led.data.pattern = app_led_pattern_call_incoming,/*0x05*/
                                                          .led.priority = LED_PRI_LOW,
                                                          .led.local_only = TRUE }},
    {.provider=ui_provider_telephony,
     .context=context_voice_in_call_with_outgoing,      { .led.action = LED_START_PATTERN,
                                                          .led.data.pattern = app_led_pattern_sco,/*0x06*/
                                                          .led.priority = LED_PRI_LOW,
                                                          .led.local_only = TRUE }},
    {.provider=ui_provider_telephony,
     .context=context_voice_in_call_with_held,          { .led.action = LED_START_PATTERN,
                                                          .led.data.pattern = app_led_pattern_sco,/*0x07*/
                                                          .led.priority = LED_PRI_LOW,
                                                          .led.local_only = TRUE }},
    {.provider=ui_provider_telephony,
     .context=context_voice_in_multiparty_call,         { .led.action = LED_START_PATTERN,
                                                          .led.data.pattern = app_led_pattern_sco,/*0x08*/
                                                          .led.priority = LED_PRI_LOW,
                                                          .led.local_only = TRUE }},
    {.provider=ui_provider_media_player,
     .context=context_media_player_streaming_sbc,       { .led.action = LED_START_PATTERN,
                                                          .led.data.pattern = app_led_pattern_streaming_sbc,/*0x09*/
                                                          .led.priority = LED_PRI_LOW}},
    {.provider=ui_provider_media_player,
     .context=context_media_player_streaming_aptx,      { .led.action = LED_START_PATTERN,
                                                          .led.data.pattern = app_led_pattern_streaming_aptx,/*0x0A*/
                                                          .led.priority = LED_PRI_LOW}},
    {.provider=ui_provider_media_player,
     .context=context_media_player_streaming_aptx_adaptive, { .led.action = LED_START_PATTERN,
                                                          .led.data.pattern = app_led_pattern_streaming_aptx_adaptive,/*0x0B*/
                                                          .led.priority = LED_PRI_LOW}},
    {.provider=ui_provider_media_player,
     .context=context_media_player_streaming_aac,       { .led.action = LED_START_PATTERN,
                                                          .led.data.pattern = app_led_pattern_streaming_aac,/*0x0C*/
                                                          .led.priority = LED_PRI_LOW}},
    {.provider=ui_provider_media_player,
     .context=context_media_player_streaming_aptx_hd,   { .led.action = LED_START_PATTERN,
                                                          .led.data.pattern = app_led_pattern_streaming_aptx_hd,/*0x0D*/
                                                          .led.priority = LED_PRI_LOW}},
    {.provider=ui_provider_media_player,
     .context=context_media_player_streaming_gaming,    { .led.action = LED_START_PATTERN,
                                                          .led.data.pattern = app_led_pattern_streaming_gaming,/*0x12*/
                                                          .led.priority = LED_PRI_LOW}},
    {.provider=ui_provider_app_sm,
     .context=context_app_sm_idle,                      { .led.action = LED_START_PATTERN,
                                                          .led.data.pattern = app_led_pattern_idle,/*0x0E*/
                                                          .led.priority = LED_PRI_LOW,
                                                          .led.local_only = TRUE }},
    {.provider=ui_provider_app_sm,
     .context=context_app_sm_idle_connected,            { .led.action = LED_START_PATTERN,
                                                          .led.data.pattern = app_led_pattern_idle_connected,/*0x0F*/
                                                          .led.priority = LED_PRI_LOW,
                                                          .led.local_only = TRUE }},
    {.provider=ui_provider_app_sm,
     .context=context_app_sm_idle_connected_two_handset,{ .led.action = LED_START_PATTERN,
                                                          .led.data.pattern = app_led_pattern_idle_connected_two_handset,/*0x10*/
                                                          .led.priority = LED_PRI_LOW,
                                                          .led.local_only = TRUE }},
    {.provider=ui_provider_app_sm,
     .context=context_app_sm_exit_idle,                 { .led.action = LED_STOP_PATTERN,
                                                          .led.data.pattern = NULL,/*0x11*/
                                                          .led.priority = LED_PRI_LOW,
                                                          .led.local_only = TRUE }},
};

const ui_event_indicator_table_t headset_ui_leds_table[] =
{
    {.sys_event=POWER_ON,                               { .led.action = LED_START_PATTERN,
                                                          .led.data.pattern = app_led_pattern_power_on,
                                                          .led.priority = LED_PRI_EVENT,
                                                          .led.local_only = TRUE },
                                                          .await_indication_completion = TRUE },

    {.sys_event=POWER_OFF,                               { .led.action = LED_START_PATTERN,
                                                          .led.data.pattern = app_led_pattern_power_off,
                                                          .led.priority = LED_PRI_EVENT,
                                                          .led.local_only = TRUE },
                                                          .await_indication_completion = TRUE },

    {.sys_event=APP_FACTORY_RESET,                       { .led.action = LED_START_PATTERN,
                                                          .led.data.pattern = app_led_pattern_factory,
                                                          .led.priority = LED_PRI_EVENT,
                                                          .led.local_only = TRUE },
                                                          .await_indication_completion = TRUE },

    {.sys_event=CHARGER_MESSAGE_DETACHED_FAKED,          { .led.action = LED_CANCEL_FILTER,
                                                          .led.data.filter = NULL,
                                                          .led.priority = LED_PRI_MEDIUM,
                                                          .led.local_only = TRUE}},

    {.sys_event=CHARGER_MESSAGE_DISABLED_FAKED,          { .led.action = LED_CANCEL_FILTER,
                                                          .led.data.filter = NULL,
                                                          .led.priority = LED_PRI_MEDIUM,
                                                          .led.local_only = TRUE}},

    {.sys_event=CHARGER_MESSAGE_COMPLETED_FAKED,         { .led.action = LED_SET_FILTER,
                                                          .led.data.filter = app_led_filter_charging_complete,
                                                          .led.priority = LED_PRI_MEDIUM,
                                                          .led.local_only = TRUE}},

    {.sys_event=CHARGER_MESSAGE_CHARGING_OK_FAKED,       { .led.action = LED_SET_FILTER,
                                                          .led.data.filter = app_led_filter_charging_ok,
                                                          .led.priority = LED_PRI_MEDIUM,
                                                          .led.local_only = TRUE}},

    {.sys_event=CHARGER_MESSAGE_CHARGING_LOW_FAKED,      { .led.action = LED_SET_FILTER,
                                                          .led.data.filter = app_led_filter_charging_low,
                                                          .led.priority = LED_PRI_MEDIUM,
                                                          .led.local_only = TRUE}},

    {.sys_event=APP_POWER_LOW,                           { .led.action = LED_START_PATTERN,
                                                          .led.data.pattern = app_led_pattern_low_power,
                                                          .led.priority = LED_PRI_EVENT,
                                                          .led.local_only = TRUE },
                                                          .await_indication_completion = TRUE },
    {.sys_event=ui_input_sm_battery_level0,              { .led.action = LED_START_PATTERN,
                                                          .led.data.pattern = app_led_pattern_battery_level0,
                                                          .led.priority = LED_PRI_EVENT,
                                                          .led.local_only = TRUE },
                                                          .await_indication_completion = TRUE },
    {.sys_event=ui_input_sm_battery_level1,              { .led.action = LED_START_PATTERN,
                                                          .led.data.pattern = app_led_pattern_battery_level1,
                                                          .led.priority = LED_PRI_EVENT,
                                                          .led.local_only = TRUE },
                                                          .await_indication_completion = TRUE },
    {.sys_event=ui_input_sm_battery_level2,              { .led.action = LED_START_PATTERN,
                                                          .led.data.pattern = app_led_pattern_battery_level2,
                                                          .led.priority = LED_PRI_EVENT,
                                                          .led.local_only = TRUE },
                                                          .await_indication_completion = TRUE },
    {.sys_event=ui_input_sm_battery_level3,              { .led.action = LED_START_PATTERN,
                                                          .led.data.pattern = app_led_pattern_battery_level3,
                                                          .led.priority = LED_PRI_EVENT,
                                                          .led.local_only = TRUE },
                                                          .await_indication_completion = TRUE },
    {.sys_event=ui_input_sm_battery_level4,              { .led.action = LED_START_PATTERN,
                                                          .led.data.pattern = app_led_pattern_battery_level4,
                                                          .led.priority = LED_PRI_EVENT,
                                                          .led.local_only = TRUE },
                                                          .await_indication_completion = TRUE },
};

uint8 HeadsetLedsConfigTable_GetSize(void)
{
    return ARRAY_DIM(headset_ui_leds_table);
}

uint8 HeadsetLedsConfigTable_ContextsTableGetSize(void)
{

    return ARRAY_DIM(headset_ui_leds_context_indications_table);
}
